# -*- codeing = utf-8 -*-
# @Time : 2021/2/22 18:46
# @Atuthor: 朱朱
# @File: 049删除列表里的空字符串.py
# @Software: PyCharm
# 删除列表里的空字符串
words = ['hello', 'good', '', '', 'yes', 'ok', '']
# for word in words:
#     if word == '':
#         words.remove(word)
# print(words)
# 上述方法没有删除最后一个空值

# i = 0
# while i<len(words):
#     if words[i]=='':
#         words.remove(words[i])
#         i-=1 # 这个很重要一定要写
#     i+=1
# print(words)
# 上述方法并不完美

# 下面这个方法比较保险,还好用
newword = []
for word in words:
    if word != '':
        newword.append(word)
words=newword
print(words)
